#include <..\\standard.hlsli>
#include <..\\WR2Parameters.hlsli>

VertexToPixel vs_main(VS_INPUT Input)
{
	VertexToPixel Output = (VertexToPixel) 0;
	Output.pos = float4(mul(Input.Position, worldViewProj));
	Output.normal = float3(normalize(mul(Input.Normal, (float3x3) world)));

	Output.kColor = float4(Input.kColor.rgb * 2, Input.kColor.a);
	//Output.kColor = float4(0.5,0.5,0.5,1);
	Output.kBlend = float4(Input.kblend);
	Output.pos2 = Input.Position;

	Output.texCoord1 = float4(Input.Tex.x,
		Input.Tex.y,
		Input.Tex.x * uvTexture2a.x + Input.Tex.y * uvTexture2a.y + uvTexture2a.w,
		Input.Tex.x * uvTexture2b.x + Input.Tex.y * uvTexture2b.y + uvTexture2b.w);

	Output.texCoord2 = float4(Input.Position.x * uvTexture1a.x + Input.Position.y * uvTexture1a.y + Input.Position.z * uvTexture1a.z + uvTexture1a.w,
		Input.Position.x * uvTexture1b.x + Input.Position.y * uvTexture1b.y + Input.Position.z * uvTexture1b.z + uvTexture1b.w,
		Input.Position.x * uvTexture2a.x + Input.Position.y * uvTexture2a.y + Input.Position.z * uvTexture2a.z + uvTexture2a.w,
		Input.Position.x * uvTexture2b.x + Input.Position.y * uvTexture2b.y + Input.Position.z * uvTexture2b.z + uvTexture2b.w);

	Output.texCoord3.xy = float2(Input.Position.x * uvTexture3a.x + Input.Position.y * uvTexture3a.y + Input.Position.z * uvTexture3a.z + uvTexture3a.w,
		Input.Position.x * uvTexture3b.x + Input.Position.y * uvTexture3b.y + Input.Position.z * uvTexture3b.z + uvTexture3b.w);

	float d = distance(Input.Position.xyz, g_CameraPosition);
	float fFogStart = 2000;
	float fFogEnd = 2500;
	Output.foger = saturate((fFogEnd - d) / (fFogEnd - fFogStart));

	return Output;
};
